import java.util.Scanner;

public class Test18 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int year = scanner.nextInt();
        int month = scanner.nextInt();
        int day = scanner.nextInt();
        //1 3 5 7 8 10 12
        //4 6 9 11
        int sum = 0;
        sum+=day;
        switch (month){
            case 12:
            case 11:
                if(month != 11)
               sum+=30;
            case 10:
                if(month != 10)
                    sum+=31;
            case 9:
                if(month != 9)
                    sum+=30;
            case 8:
                if(month != 8)
                    sum+=31;
            case 7:
                if(month != 7)
                    sum+=31;
            case 6:
                if(month != 6)
                    sum+=30;
            case 5:
                if(month != 5)
                    sum+=31;
            case 4:
                if(month != 4)
                    sum+=30;
            case 3:
                if(month != 3)
                    sum+=31;
            case 2:
                //判断是否是闰年
                if((month!=2)&&((year % 400 ==0) || (year%4 == 0 && year%100!=0))){
                    sum+=29;
                }else if(month!=2){
                    sum+=28;
                }

            case 1:
                if(month != 1)
                    sum+=31;
        }
        System.out.println(sum);
    }
}
